package org.heng.controller;

import lombok.RequiredArgsConstructor;
import org.heng.commons.result.Result;
import org.heng.dto.req.CancelSeatReqDTO;
import org.heng.dto.req.CreateSeatReqDTO;
import org.heng.dto.req.QueryAvaliableSeatReqDTO;
import org.heng.dto.resp.AvaliableSeatRespDTO;
import org.heng.service.SeatService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class SeatController {
    private final SeatService seatService;

    @PostMapping("query/available/seat")
    public Result<AvaliableSeatRespDTO> queryAvailableSeat(@RequestBody QueryAvaliableSeatReqDTO requestParams) {
        return new Result<AvaliableSeatRespDTO>().setData(seatService.queryAvaliableSeat(requestParams));
    }

    @PostMapping("/create/seat")
    public Result<Void> createSeat(@RequestBody CreateSeatReqDTO requestParams) {
        seatService.createSeat(requestParams);
        return new Result<Void>().setMsg("创建成功");
    }

    @PostMapping("/cancel/seat")
    public void cancelSeat(CancelSeatReqDTO requestParams) {
        seatService.cancelSeat(requestParams);
    }
}
